import request from '@/utils/request'
import {POS_SERVER_URL} from '@/utils/common'
import {getSignedParams} from '@/utils/sign'

/**
 * 根据openid获取会员信息
 * @param {*} openid string
 */
export function getMemberInfoByOpenid (openid) {
  return request({
    url: POS_SERVER_URL + '/api/pc/member-info-by-openid',
    method: 'post',
    data: getSignedParams({'openid': openid})
  })
}

/**
 * 根据电话号码获取会员信息
 * @param {*} phone string
 */
export function getMemberInfoByPhone (phone) {
  return request({
    url: POS_SERVER_URL + '/api/pc/member-info-by-phone',
    method: 'post',
    data: getSignedParams({'phone': phone})
  })
}

/**
 * 获取会员可用优惠券列表
 * @param {} params
 */
export function getUsableCoupons (params) {
  return request({
    url: POS_SERVER_URL + '/api/pc/usable-coupon-records',
    method: 'post',
    data: getSignedParams(params)
  })
}

/**
 * 获取没激活会员列表
 */
export function getNotActiveMembers () {
  return request({
    url: POS_SERVER_URL + '/api/pc/not-active-member-list',
    method: 'post',
    data: getSignedParams({})
  })
}

export function activateMember (data) {
  return request({
    url: POS_SERVER_URL + '/api/pc/activate-member',
    method: 'post',
    data: getSignedParams(data)
  })
}

/**
 * 拒绝该名审核激活会员
 * @param data
 * @returns {*}
 */
export function removeAuditMember (data) {
  return request({
    url: POS_SERVER_URL + '/api/pc/removeActivationAuditMember',
    method: 'post',
    data: getSignedParams(data)
  })
}

/**
 * 获取会员可用积分（按站）
 * @param memberId
 * @param stationId
 * @returns {*}
 */
export function getMemberPoints (memberId, stationId) {
  return request({
    url: POS_SERVER_URL + '/api/pc/member-points-info',
    method: 'post',
    data: getSignedParams({'memberId': memberId, 'stationId': stationId})
  })
}
